#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int x, ans = 0;
	while (cin >> x) {
		if (x / 1000 == x / 10 % 10 && x / 100 % 10 + 1 == x % 10)
			ans++;
	}
	cout << ans;
	return 0;
}
